<?php
session_start();
include "library.php";

//Redirect user if not logged in

if(!isset($_SESSION["username"])){
	header("Location:login.php");
}

//If user preses logout button, clear session, redirect

if(isset($_POST["logout"])){	
	session_unset();
	session_destroy();
	header("Location:home.php");
}

//Print header
print_header($_SESSION["position"], 1);


//If user presses submit, direct to correct page

if(isset($_POST["add1"])){
	if($_POST["choices"] == "UserPerm"){ //User selects Manage User Permisions
		header("Location:UserPerm.php");	
	}
	if($_POST["choices"] == "UserPend"){  //User selects Manage Pending Users
		header("Location:UserPend.php");	
	}
	if($_POST["choices"] == "UpFile"){   //User selects Upload File
		header("Location:UpFile.php");
	}
	if($_POST["choices"] == "SearchFile"){   //User selects Search File
		header("Location:SearchFile.php");
	}
	if($_POST["choices"] == "SuggestFile"){   //User selects Search File
		header("Location:SuggestFile.php");
	}
	if($_POST["choices"] == "ApproveFile"){   //User selects Search File
		header("Location:ApproveFile.php");
	}
	if($_POST["choices"] == "AccountInfo"){   //User selects Search File
		header("Location:AccountInfo.php");
	}
	if($_POST["choices"] == "Preapprove"){   //User selects Search File
		header("Location:Preapprove.php");
	}
}

//Three Unique Home pages are needed depending on the type of user that is logged in
//1)Admin => Manage Permisisions, search File
//2)Lead Researcher
//3)Researcher

if($_SESSION["position"] == 1){ //Admin
?>

	<h2 class="title"><u>You logged into PHYS-FILES! Enjoy.</u></h2><BR><BR><BR><BR>
	<h2 class="title">What would you like to do first?</h2>
<?php
} else if($_SESSION["position"] == 2){ //Lead Researcher
?>
	<h2 class="title"><u>You logged into PHYS-FILES! Enjoy.</u></h2><BR><BR><BR><BR>
	<h2 class="title">What would you like to do first?</h2>
<?php 
} else if($_SESSION["position"] == 3){ //Researcher
?>
	<h2 class="title"><u>You logged into PHYS-FILES! Enjoy.</u></h2><BR><BR><BR><BR>
	<h2 class="title">What would you like to do first?</h2>
<?php
}
print_footer();
?>